﻿<%@ page language="java" import="web_hr.Model,java.util.*,java.sql.*" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    
<% 
String user = new String(request.getParameter("username").getBytes("ISO-8859-1"),"UTF-8");
boolean flag = false;
String str = "\\w{1,20}";		//uname必须为数字，字母，或下划线。
if(user.matches(str)){
	flag = true;
}else{
	out.println("<span id = 'w1'><font color = red>UserName must be letters or digits or underscore!<font></span>");
}

if(flag==true){  
	Model m=new Model("hr_employee");
	 ResultSet rs=m.eQuery("select * from hr_employee where username='"+user+"'");//判断数据库是否已经存在。
		
		if(rs.next()){
			out.println("<span id='w1'><font color = red>The username is existed!</font></span>");
			}else{
			out.println("<span id='w1'><font color = green>Username is available!</font></span>");
			}	
		m.close();
	}
	
%>